package viqiang.ye.springdemo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import viqiang.ye.springdemo.config.WebConfig;

import java.util.Arrays;

@SpringBootApplication
public class SpringDemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringDemoApplication.class, args);

        // 返回 IOC 容器，使用注解配置，传入配置类
//        ApplicationContext context = new AnnotationConfigApplicationContext(WebConfig.class);
//        User user = context.getBean(User.class);
//        System.out.println(user);

        ApplicationContext context = new AnnotationConfigApplicationContext(WebConfig.class);
        // 查看基于注解的 IOC容器中所有组件名称
        String[] beanNames = context.getBeanDefinitionNames();
        Arrays.stream(beanNames).forEach(System.out::println);
	}

}
